package com.gzcc.apicontroller;

import com.gzcc.common.ResponseCode;
import com.gzcc.model.Product;
import com.gzcc.repository.ProductRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author: Mr.Zhong
 * @create: 2018-06-25 11:06
 * @description: 商品接口
 **/
@Api(value = "商品接口服务",description = "商品的api接口")
@Controller
@RequestMapping("/api/productApi")
public class ProductApiController {

    @Autowired
    private ProductRepository productRepository;

    /**
    * 描述: 商品列表api接口
    * @return  ResponseCode<List<Product>>
    * @Author: Mr.Zhong
    * @Date: 2018/6/25
    */
    @ApiOperation("获取商品列表")
    @GetMapping("/list")
    @ResponseBody
    public ResponseCode<List<Product>> list(){
        return new ResponseCode(200,"获取成功",productRepository.findAll());
    }



}
